package org.acy.train.member.controller;

import jakarta.annotation.Resource;
import org.acy.train.common.resp.CommonResp;
import org.acy.train.member.req.MemberRegisterReq;
import org.acy.train.member.service.MemberService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 旅客相关接口
 *
 * @author yust
 */
@RestController
@RequestMapping("/member")
public class MemberController {

    @Resource
    MemberService memberService;

    /**
     * 旅客数量
     *
     * @return 数量值
     */
    @GetMapping("/count")
    public CommonResp<Integer> memberCount() {
        Integer count = memberService.memberCount();
        return CommonResp.success(count);
    }

    /**
     * 注册旅客信息
     *
     * @param req 注册信息
     * @return 返回id
     */
    @PostMapping("/register")
    public CommonResp<Long> register(@Validated MemberRegisterReq req) {
        Long id = memberService.register(req);
        return CommonResp.success(id);
    }
}
